package com.youshang520i.consuldiscoveryprovider;

import com.alibaba.fastjson.JSONObject;
import com.youshang520i.consuldiscoveryprovider.model.Goods;
import com.youshang520i.consuldiscoveryprovider.model.Student;
import com.youshang520i.consuldiscoveryprovider.service.GoodsService;
import lombok.Data;
import lombok.ToString;
import lombok.extern.log4j.Log4j2;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

@Log4j2
@RestController
@SpringBootApplication
@MapperScan("com.youshang520i.consuldiscoveryprovider.mapper")
public class ConsulDiscoveryProvider {



    public static void main(String[] args) {
        SpringApplication.run(ConsulDiscoveryProvider.class, args);
    }


    //重点： Value 不会起到针对Consul动态加载配置文件的作用
    @Value("${config.env}")
    public String env1;

    @PostConstruct
    public void init2(){
        log.info("env1:  " + env1);
    }

    @Value("${server.port}")
    public String port;

    @GetMapping("/init")
    public String init(){
        return "ConsulDiscoveryProvider : init = " + port;
    }

    @RequestMapping("/query")
    public String query(Student student){
        return student.toString();
    }

}
